# -*- coding:utf-8 -*-

from flask import Flask
from flask_sqlalchemy import SQLAlchemy,declarative_base
from sqlalchemy.sql.functions import now
from sqlalchemy import Column, Integer, String, DateTime, Boolean, Text, Float, ForeignKey

# Base = declarative_base()

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:123456@localhost:3306/hospital'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
db = SQLAlchemy(app)


class Hospital(db.Model):

    __tablename__ = 'yd_hospital'
    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(255))
    alias = db.Column(db.String(255), doc='医院别名')
    nature = db.Column(db.String(64), doc='医院性质')
    grade = db.Column(db.String(64),  doc='医院等级')
    property = db.Column(db.String(64),  doc='医院等级')
    tel = db.Column(db.String(64),  doc='医院联系电话')
    website = db.Column(db.String(128),  doc='医院网址')
    address = db.Column(db.String(255),  doc='医院地址')
    fax_no = db.Column(db.String(32),  doc='传真')
    email = db.Column(db.String(64),  doc='医院地址')
    post_code = db.Column(db.String(64),  doc='医院邮编')
    dean = db.Column(db.String(32), doc='医院院长')
    bed_number = db.Column(db.Integer,  doc='医院地址')
    department_number = db.Column(db.Integer, doc='科室数量')
    clinics_number = db.Column(db.Integer,  doc='年门诊数量')
    district = db.Column(db.DateTime(), doc='所在地区')
    created_time = db.Column(db.String(32), doc='创建时间')
    is_health_insurance = db.Column(Boolean, default=0, doc='是否医保')
    summary = db.Column(db.Text(),  doc='医院简介')
    advanced_equipment = db.Column(db.Text(),  doc='现金设备')
    bus_route = db.Column(db.String(255),  doc='医院简介')
    medical_score = db.Column(db.Integer,default=0, doc='医疗评分')
    price_score = db.Column(db.Integer, default=0, doc='价格评分')
    service_score = db.Column(db.Integer,default=0,  doc='服务评分')
    is_private = db.Column(Boolean, default=0, doc='是否私营')
    honor = db.Column(db.Text(), default=0, doc='所获荣耀')
    gmt_created = db.Column(db.DateTime(), doc='', default=now())
    gmt_modified = db.Column(db.DateTime(), doc='', default=DateTime())
    deleted = db.Column(Boolean, default=0, doc='')


class Category(db.Model):

    __tablename__ = 'yd_category'
    id = db.Column(db.Integer(), primary_key=True, nullable=False, doc='')
    name = db.Column(db.String(255), doc='分类名称')
    gmt_created = db.Column(DateTime(), doc='', default=now())
    gmt_modified = db.Column(DateTime(), doc='', default=now())
    deleted = db.Column(Boolean, default=0, doc='')

class Department(db.Model):

    __tablename__ = 'yd_department'
    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(255), doc='')
    category_id = db.Column(db.Integer(), doc='')
    remark = db.Column(db.String(125), doc='备注')
    gmt_created = db.Column(db.DateTime(), doc='', default=now())
    gmt_modified = db.Column(db.DateTime(), doc='', default=now())
    deleted = db.Column(Boolean, default=0, doc='')

class User(db.Model):

    __tablename__ = 'yd_user'
    id = db.Column(Integer(), primary_key=True)
    username = db.Column(String(255))
    password = db.Column(String(255))
    gmt_created = db.Column(DateTime(), doc='', default=now())
    gmt_modified = db.Column(DateTime(), doc='', default=now())
    deleted = db.Column(Boolean, default=0, doc='')

if __name__ == '__main__':
    db.create_all()
